package guda.stark.dal.dao.impl;

import guda.grape.autogen.common.BaseDAO;
import guda.stark.dal.dao.ParkingDAO;
import guda.stark.dal.dataobject.ParkingDO;
import guda.grape.autogen.common.page.BaseQuery;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ParkingDAOImpl extends BaseDAO implements ParkingDAO {

    @Override
	public Long insert(ParkingDO parking) {
	      try {
                return (Long) getSqlMapperW().insert("parking.insert",parking);
          } catch (Exception e) {
                throw new RuntimeException(e);
          }

	}

    @Override
	public ParkingDO getParkingById(Long parkingId) {
	    return (ParkingDO)getSqlMapClientTemplate().queryForObject("parking.getParkingById", parkingId);
	}

    @Override
	public boolean delParkingById(Long parkingId) {
	    int num = 0;
        try {
            num = getSqlMapperW().delete("parking.delParkingById",parkingId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        if(num>0){
            return true;
        }else{
            return false;
        }
	}

    @Override
	public List<ParkingDO> getParkingByIds(List idsList) {
        Map m = new HashMap();
        m.put("idsList",idsList);
		return getSqlMapClientTemplate().queryForList("parking.selectByIds", m);
	}

    @Override
	public void cleanAutoIncrement(Long parkingId) {
	    try {
            getSqlMapperW().update("parking.cleanAutoIncrement",parkingId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
	}

    @Override
    public List<ParkingDO> selectForPage(BaseQuery baseQuery) {
        return getSqlMapClientTemplate().queryForList("parking.selectForPage", baseQuery);
    }

    @Override
    public int countForPage(BaseQuery baseQuery) {
        return (Integer)getSqlMapClientTemplate().queryForObject("parking.countForPage",baseQuery);
    }

    @Override
    public void updateByIdSelective(ParkingDO parking) {
        try {
            getSqlMapperW().update("parking.updateByIdSelective",parking);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}

